﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Empires.Infrastructure.Entities.Repository;

namespace Empires.Infrastructure.Entities.Entity
{
    public class Templete : IAccessible<T_Templete, Templete>, ILogicEntity<T_Templete, Templete>
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Sample { get; set; }
        public string Description { get; set; }
        public string Path { get; set; }
        public string Creator { get; set; }
        public DateTime CreateTime { get; set; }
        public bool IsPrivate { get; set; }
        public bool Available { get; set; }

        protected override void Covariant(T_Templete model)
        {
            if (model != null)
            {
                this.Id = model.Id;
                this.Name = model.Name;
                this.Description = model.Description;
                this.Creator = model.Creator;
                this.CreateTime = model.CreateTime;
                this.IsPrivate = model.IsPrivate;
                this.Available = model.Available;
                this.Sample = model.Sample;
                this.Path = model.Path;
            }
        }

        protected override T_Templete Inverter(Templete model)
        {
            if (model != null)
            {
                return new T_Templete()
                {
                    Available = model.Available,
                    CreateTime = model.CreateTime,
                    Description = model.Description,
                    Id = model.Id,
                    IsPrivate = model.IsPrivate,
                    Name = model.Name,
                    Creator = model.Creator,
                    Sample=model.Sample,
                    Path=model.Path
                };
            }
            return null;
        }

        public Templete Set(T_Templete dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
